package patrol.mobile.com.mobilepatrol.manager;

import java.util.List;

import io.realm.Realm;
import patrol.mobile.com.mobilepatrol.PatrolApp;
import patrol.mobile.com.mobilepatrol.bean.Car;

/**
 * Created by apple on 17/11/20.
 */

public class CarManager {
    public static void delAllCars(){
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.delete(Car.class);
            }
        });
    }
    public static List<Car> getAllCars(){
        return PatrolApp.realm.where(Car.class).equalTo("org_No",UserManager.getOrgNo()).findAll();
    }
    public static boolean isNull(){
        if (getAllCars().size()>0){
            return false;
        }else{
            return true;
        }
    }
    public static Car getFirstCar(){
        return PatrolApp.realm.where(Car.class).equalTo("org_No",UserManager.getOrgNo()).findFirst();
    }
}
